import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_types.dart';
import 'package:xindong/manager/xindong_chat_singleton.dart';
import 'package:xindong/models/chat_message/xindong_custom_message.dart';
import 'package:xindong/res/assets_res.dart';
import 'package:xindong/utils/xindong_image_util.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';

class XinDongLiaoTianMessageCallingCancel extends StatelessWidget {
  final V2TimMessage message;
  final XinDongCustomMessage model;

  const XinDongLiaoTianMessageCallingCancel({Key? key, required this.message, required this.model})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    final isFromSelf = message.isSelf == true;
    final backgroundColor = isFromSelf ? Colors.grey.shade300 : Colors.white;
    final isAudio = int.parse("${model.chat_type}") == ChatType.callAudio;
    String imageName = isAudio ? AssetsRes.CALL_TIME_AUDIO : AssetsRes.CALL_TIME_VIDEO;
    String typeName = isAudio ? "[语音通话]" : "[视频通话]";
    return GetBuilder<XinDongChatSingleton>(
      builder: (controller) {
        return Container(
          padding: const EdgeInsets.all(10),
          decoration: BoxDecoration(color: backgroundColor, borderRadius: BorderRadius.circular(10)),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ImageUtil.asset(imageName, width: 20, height: 14, fit: BoxFit.contain),
              Text(
                " $typeName${model.content}",
                style: const TextStyle(fontSize: 16, height: 1.2, color: DZColors.titleColor),
              ),
            ],
          ),
        );
      },
    );
  }
}
